/*
 * Copyright 2017 Baiyyy
 * @(#)CCTSServerInitializer.java
 */

package com.byyy.ccts.modules.cc.server;

import com.byyy.ccts.modules.cc.server.codec.CCTSServerDecoder;
import com.byyy.ccts.modules.cc.server.codec.CCTSServerEncoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by DELL on 2018-4-28.
 */
@Service("cctsServerInitializer")
public class CCTSServerInitializer extends ChannelInitializer<SocketChannel> {

    @Autowired
    private CCTSServerHandler cctsServerHandler;

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline pipeline = socketChannel.pipeline();
        // 自己的逻辑Handler
        pipeline.addLast(new CCTSServerEncoder());
        pipeline.addLast(new CCTSServerDecoder());
        pipeline.addLast(cctsServerHandler);
    }

}
